﻿using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace MyLib.Web.Pages {
	/// <summary>
	/// 
	/// </summary>
	public abstract class Error404Page : ErrorPage {
		/// <summary>
		/// 
		/// </summary>
		private void InitContents() {
			var image1 = this.FindDescendantControl<HtmlImage>("ErrorImage");

			var imageUrl = GetErrorImagePath();
			if (!string.IsNullOrWhiteSpace(imageUrl)) {
				image1.Src = ResolveClientUrl(imageUrl);
				image1.Visible = true;
			} else {
				image1.Visible = false;
			}

			var literal1 = this.FindDescendantControl<Control>("ErrorTitle") as ITextControl;
			var literal2 = this.FindDescendantControl<Control>("ErrorGuide") as ITextControl;

			if (literal1 != null) {
				literal1.Text = Properties.Main.ErrorPageNotFound;
			}
			if (literal2 != null) {
				literal2.Text = Properties.Main.ErrorPageNotFound2;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		protected override void OnInit(EventArgs e) {
			base.OnInit(e);

			this.Title = Properties.Main.ErrorPageNotFound;

			InitContents();
		}
	} // end of MyPage.
}
